﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using sexhealth.console.service.post.vo;
using sexhealth.console.service.post;
using System.Collections;

public partial class usercontrol_LeftChannelList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            if (Request["chid"] != null)
            {
                if (Request["chid"] == "21")
                {
                    pnlWhatis.Visible = true;
                }
                else 
                {
                    pnlWhatis.Visible = false;
                }
                PostService postService = new PostService();
                int parentChannelId = postService.DaoGetVOById<ChannelVO>(int.Parse(Request["chid"])).ParentId;
                StringBuilder sb = new StringBuilder();
                IList<ChannelVO> chList = new List<ChannelVO>();
                if (parentChannelId == 0)
                {
                    chList = postService.GetChannelList(int.Parse(Request["chid"]));
                }
                else if (parentChannelId == 1)
                {
                    chList.Add(postService.DaoGetVOById<ChannelVO>(int.Parse(Request["chid"])));
                }
                else
                {
                    chList = postService.GetChannelList(parentChannelId);
                }
                foreach (ChannelVO ch in chList)
                {
                    sb.Append("<div id='leftbtn'>");
                    sb.Append("<table border='0' cellspacing='0' cellpadding='0'>");
                    sb.Append("<tr>");
                    sb.Append("<td height='31' valign='bottom'>");
                    if (ch.ChannelNo == 14 || ch.ChannelNo == 15)
                    {
                        sb.Append(" <a href='medialist.aspx?chid=" + ch.ChannelNo.ToString() + "' class='b03'>" + ch.Name + "</a>");
                    }
                    else
                    {
                        sb.Append(" <a href='postlistdate.aspx?chid=" + ch.ChannelNo.ToString() + "' class='b03'>" + ch.Name + "</a>");
                    }
                    sb.Append("</td>");
                    sb.Append("</tr>");
                    sb.Append("</table>");
                    sb.Append("</div>");
                }
                ltlChannelList.Text = sb.ToString();
            }
        }
    }
}
